package sifeap.pl.managedbean.usuarios;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import sifeap.pl.util.FacesUtils;

@ManagedBean(name = "menuUsuarioManagedBean")
@RequestScoped
public class MenuUsuarioManagedBean {
	
	public String irAdministracionEventos() {
		String[] managedBeans = {"eventosManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/eventos/eventos.jsf?faces-redirect=true";
	}
	
	public String irAdministracionUsuarios() {
		String[] managedBeans = {"usuariosManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/usuarios/usuarios.jsf?faces-redirect=true";
	}
	
	public String irAdministracionConvenios() {
		String[] managedBeans = {"conveniosManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/convenios/convenios.jsf?faces-redirect=true";
	}
	
	public String irCambiarContrasena() {
		String[] managedBeans = {"cambiarContrasenaManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/usuarios/cambiarContrasena.jsf?faces-redirect=true";
	}
	
	public String irSolicitarCredito() {
		String[] managedBeans = {"simuladorManagedBean", "misSolicitudesCreditoManagedBean", "consultarSolicitudesCreditoManagedBean", "solicitudCreditoManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/solicitudesCredito/solicitudCredito.jsf?faces-redirect=true";
	}
	
	public String irSolicitarAuxilio() {
		String[] managedBeans = {"misSolicitudesAuxilioManagedBean", "consultarSolicitudesAuxilioManagedBean", "solicitudAuxilioManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/solicitudesAuxilio/solicitudAuxilio.jsf?faces-redirect=true";
	}
	
	public String irMisSolicitudesCredito() {
		String[] managedBeans = {"simuladorManagedBean", "misSolicitudesCreditoManagedBean", "consultarSolicitudesCreditoManagedBean", "solicitudCreditoManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/solicitudesCredito/misSolicitudes.jsf?faces-redirect=true";
	}
	
	public String irConsultarSolicitudesCredito() {
		String[] managedBeans = {"simuladorManagedBean", "misSolicitudesCreditoManagedBean", "consultarSolicitudesCreditoManagedBean", "solicitudCreditoManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/solicitudesCredito/consultarSolicitudes.jsf?faces-redirect=true";
	}
	
	public String irMisSolicitudesAuxilio() {
		String[] managedBeans = {"misSolicitudesAuxilioManagedBean", "consultarSolicitudesAuxilioManagedBean", "solicitudAuxilioManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/solicitudesAuxilio/misSolicitudes.jsf?faces-redirect=true";
	}
	
	public String irConsultarSolicitudesAuxilio() {
		String[] managedBeans = {"misSolicitudesAuxilioManagedBean", "consultarSolicitudesAuxilioManagedBean", "solicitudAuxilioManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/solicitudesAuxilio/consultarSolicitudes.jsf?faces-redirect=true";
	}
	
	public String irSimuladorCredito() {
		String[] managedBeans = {"simuladorManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/simulador/simuladorCredito.jsf?faces-redirect=true";
	}
	
	public String irReportesSolicitudCredito() {
		String[] managedBeans = {"reporteCreditoManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/reportes/solicitudesCredito.jsf?faces-redirect=true";
	}
	
	public String irReportesSolicitudAuxilio() {
		String[] managedBeans = {"reporteAuxilioManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/reportes/solicitudesAuxilio.jsf?faces-redirect=true";
	}
	
	public String irReportesCantidadCreditos() {
		String[] managedBeans = {"cantidadCreditosManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/reportes/cantidadCreditos.jsf?faces-redirect=true";
	}
	
	public String irReportesCantidadAuxilios() {
		String[] managedBeans = {"cantidadAuxiliosManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/reportes/cantidadAuxilios.jsf?faces-redirect=true";
	}
	
	public String irReportesEstadoCuenta() {
		String[] managedBeans = {"estadoCuentaManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/reportes/estadoCuenta.jsf?faces-redirect=true";
	}
	
	public String irReportesCarteraCredito() {
		String[] managedBeans = {"carteraCreditoManagedBean"};
		eliminarManagedBean(managedBeans);
		
		return "/web/reportes/carteraLineaCredito.jsf?faces-redirect=true";
	}
	
	/**
	 * Elimina de la sesion los MB
	 * @param managedBeans
	 */
	public static void eliminarManagedBean(String[] managedBeans) {
		if (managedBeans != null) {
			for (String managedBean : managedBeans) {
				FacesUtils.removeSessionAttribute(managedBean);
			}
		}
	}
}
